#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main()
{
    size_t d, n;
    std::cin >> d;
    std::vector<double> left(d), right(d);

    for (size_t i = 0; i < d; ++i)
         std::cin >> left[i];

    for (size_t i = 0; i < d; ++i)
        std::cin >> right[i];
    for (size_t i = 0; i < d; ++i)
        right[i] += left[i];

    std::cin >> n;
    std::vector<size_t> ans;
        
    for (size_t i = 0; i < n; ++i)
    {
         bool in = true;
         for (size_t j = 0; j < d; ++j)
         {
              double coord_j;
              std::cin >> coord_j;
              if (in)
                  if (coord_j < left[j] || coord_j >= right[j]) in = false;
         }
         if (in) ans.push_back(i + 1);
     }
     std::sort(ans.begin(), ans.end());
     if (ans.size() == 0) ans.push_back(n + 1);
     std::cout << ans.size() << "\n";
     for (size_t i = 0; i < ans.size(); ++i)
         std::cout << ((ans[i] != n + 1) ? (int)ans[i] : (int)-1) << " "; 
     return 0;
}